<?php
/*
 * 主要功能:
 *
 * dreamxyp(QQ:31996798) - PHP - class.log.php
 * coding:夏一平
 * 創建時間:2006-11-2
 */
class log
{
	/*
	 * 功能:寫Log
	 */
	static public function write($content,$key,$skey='')
	{
		global $db;
		$data =array(
			'key'		=>$key,
			'skey'		=>$skey,
			'content'	=>$content
		);
		return $db->insert('do_log',$data);
	}
	/*
	 * 功能:讀取Log
	 */
	static public function read($key,$skey='',$max=100,$begin=0)
	{
		global $db;
		$sql = 'select * from do_log where key = :key ';
		$bind	= array(
			'key'	=>$key,
		);
		if($skey)
		{
			$bind['skey'] = $skey;
			$sql .= ' and skey = :skey ';
		}
		$sql = 'order by id desc limit '.$begin.','.$max.';';
		return $db->dataArray($sql,$bind);
	}
	/*
	 * 功能:刪Log
	 */
	static public function del($id)
	{
		global $db;
		return $db->delete('do_log',' id =:id ',$id);
	}
}
?>
